package controller.api;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Kv;

import common.inter.ServiserInter;
import service.CompanyService;

public class ApiCompanyController extends BaseApiController {
	@Inject CompanyService companyService ;

	@Before(ServiserInter.class)
	public void search() {
		String name = getPara("name");
	    renderJson(companyService.search(name));
    }
	
	public void list() {
	    Kv kv = getParamKv() ;
	    if (getWxuser().isSeviserRole() || getWxuser().isStaffRole()) {
	    	kv.set("tsc.serviserId" , getWxuser().getCompanyId() );
		}
	    Integer pageNumber = getParaToInt("pageNumber", 1);
	    Integer pageSize = getParaToInt("pageSize", 10);
	    set("page", companyService.getApiPage( kv , pageNumber, pageSize));
	    renderJson();
	}
	
}
